package com.jzo2o.foundations.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.foundations.model.dto.request.ServePageQueryReqDTO;
import com.jzo2o.foundations.model.dto.request.ServeUpsertReqDTO;
import com.jzo2o.foundations.model.dto.response.ServeResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 服务表 前端控制器
 *
 * @Author shd
 * @Date 2025/9/7 19:36
 */
@RestController("operationServeController")
@RequestMapping("/operation/serve")
@Api(tags = "运营端 - 服务相关接口")
public class ServeController {
    @Autowired
    private IServeService serveService;

    @GetMapping("/page")
    @ApiOperation("服务分页查询")
    public PageResult<ServeResDTO> page(ServePageQueryReqDTO servePageQueryReqDTO){
        return serveService.pageList(servePageQueryReqDTO);
    }

    @ApiOperation("添加服务")
    @PostMapping("/batch")
    public void batchAdd(@RequestBody List<ServeUpsertReqDTO> dtoList){
        serveService.batchAdd(dtoList);
    }

    @ApiOperation("修改服务价格")
    @PutMapping("/{id}")
    public void updatePrice(@PathVariable("id") Long id,@RequestParam("price") BigDecimal price){
        serveService.updatePrice(id,price);
    }
}
